<script setup lang="ts">
import { useGuessList1 } from '@/composables'

const { guessRef, onScrolltolower } = useGuessList1()
</script>

<template>
  <scroll-view scroll-y class="scroll-view" @scrolltolower="onScrolltolower">
    <template v-if="true"
      ><view class="cart-list">
        <!-- 优惠提示 -->
        <view class="tips">
          <text class="label">满减</text>
          <text class="desc">满1件，即可享受9折优惠</text>
        </view>
        <uni-swipe-action>
          <uni-swipe-action-item v-for="item in 2" :key="item" class="cart-swipe">
            <view class="goods">
              <text class="checkbox" :class="{ checked: true }"></text>
              <navigator
                class="navigator"
                url="/pages/goods/goods?id=1435025"
                open-type="navigate"
                hover-class="none"
              >
                <image
                  src="https://yanxuan-item.nosdn.127.net/da7143e0103304f0f3230715003181ee.jpg"
                  mode="aspectFit"
                  class="picture"
                />
                <view class="meta">
                  <view class="name ellipsis">人手必备，儿童轻薄透气防蚊裤73-140cm</view>
                  <view class="attrsText">黄色小象，73cm</view>
                  <view class="price">69.00</view>
                </view>
              </navigator>
              <view class="count">
                <text class="text">-</text>
                <input type="number" class="input" value="1" />
                <text class="text">+</text>
              </view>
            </view>
            <template #right>
              <view class="cart-swipe-right">
                <button class="button delete-button">删除</button>
              </view>
            </template>
          </uni-swipe-action-item>
        </uni-swipe-action>
      </view>
      <!-- 购物车空状态 -->
      <!-- <view class="cart-blank">
        <image src="/static/images/cart-blank.png" class="image" />
        <text class="text">购物车还是空的，快来挑选好货吧</text>
        <navigator url="/pages/index/index" open-type="switchTab" hover-class="none">
          <button class="button">去首页看看</button>
        </navigator>
      </view> -->
      <!-- 吸底工具栏 -->
      <view class="toolbar">
        <text class="all" :class="{ checked: true }">全选</text>
        <text class="text">合计：</text>
        <text class="amount">100</text>
        <view class="button-group">
          <view class="button payment-button" :class="{ disabled: true }">去结算</view>
        </view>
      </view>
    </template>

    <!-- 未登录：提示登录 -->
    <!-- <view class="login-blank">
      <text class="text">登录后可查看购物车中商品</text>
      <navigator url="/pages/login/login" open-type="navigate" hover-class="none">
        <button class="button">去登录</button>
      </navigator>
    </view> -->

    <!-- 猜你喜欢 -->
    <XtxGuess1 ref="guessRef" />
    <!-- 底部占位空盒子 -->
    <!-- <view class="toolbar-height"></view> -->
  </scroll-view>
</template>
<style lang="scss" scoped>
:host {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #f7f7f7;
}
.scroll-view {
  height: 100vh;
  flex: 1;
}
.cart-list {
  padding: 0 20rpx;
}
.tips {
  display: flex;
  align-items: center;
  line-height: 1;
  margin: 30rpx 10rpx;
  font-size: 26rpx;
  color: #666;

  .label {
    color: #fff;
    padding: 7rpx 15rpx 5rpx;
    border-radius: 4rpx;
    font-size: 24rpx;
    background-color: #27ba9b;
    margin-right: 10rpx;
  }
}

.goods {
  display: flex;
  padding: 20rpx 20rpx 20rpx 80rpx;
  border-radius: 10rpx;
  background-color: #fff;
  position: relative;
  :deep(.navigator a) {
    display: flex;
  }
  .checkbox {
    position: absolute;
    top: 0;
    left: 0;

    display: flex;
    justify-content: center;
    align-items: center;
    width: 80rpx;
    height: 100%;
    &::before {
      content: '\e6cd';
      font-family: 'erabbit' !important;
      font-size: 40rpx;
      color: #444;
    }
    &.checked::before {
      content: '\e6cc';
      color: #27ba9b;
    }
  }

  .picture {
    width: 170rpx;
    height: 170rpx;
  }
  .meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 20rpx;
  }
  .name {
    height: 72rpx;
    font-size: 26rpx;
    color: #444;
  }
  .attrsText {
    line-height: 1.8;
    padding: 0 15rpx;
    font-size: 24rpx;
    align-self: flex-start;
    border-radius: 4rpx;
    color: #888;
    background-color: #f7f7f8;
  }
  .price {
    line-height: 1;
    font-size: 26rpx;
    margin-bottom: 2rpx;
    color: #cf4444;
    &::before {
      content: '￥';
      font-size: 80%;
    }
  }
  .count {
    position: absolute;
    bottom: 20rpx;
    right: 5rpx;

    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 220rpx;
    height: 48rpx;

    .text {
      height: 100%;
      padding: 0 20rpx;
      font-size: 32rpx;
      color: #444;
    }
    .input {
      height: 100%;
      text-align: center;
      border-radius: 4rpx;
      font-size: 24rpx;
      color: #444;
      background-color: #f6f6f6;
    }
  }
}
.cart-swipe {
  display: block;
  margin: 20rpx 0;
}
.cart-swipe-right {
  display: flex;
  height: 100%;
  .button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50rpx;
    padding: 6rpx;
    line-height: 1.5;
    color: #fff;
    font-size: 26rpx;
    border-radius: 0;
  }
  .delete-button {
    background-color: #cf4444;
  }
}

// 空状态
.cart-blank,
.login-blank {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 60vh;
  .image {
    width: 400rpx;
    height: 281rpx;
  }
  .text {
    color: #444;
    font-size: 26rpx;
    margin: 20rpx 0;
  }
  .button {
    width: 240rpx !important;
    height: 60rpx;
    line-height: 60rpx;
    margin-top: 20rpx;
    font-size: 26rpx;
    border-radius: 60rpx;
    color: #fff;
    background-color: #27ba9b;
  }
}

.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--window-bottom);
  z-index: 1;

  height: 100rpx;
  padding: 0 20rpx;
  display: flex;
  align-items: center;
  border-top: 1rpx solid #ededed;
  border-bottom: 1rpx solid #ededed;
  background-color: #fff;
  box-sizing: content-box;
  .all {
    margin-left: 25rpx;
    font-size: 14px;
    color: #444;
    display: flex;
    align-items: center;
    &::before {
      content: '\e6cd';
      font-family: 'erabbit' !important;
      font-size: 40rpx;
      margin-right: 8rpx;
    }
    &.checked::before {
      content: '\e6cc';
      color: #27ba9b;
    }
  }
  .text {
    margin-right: 8rpx;
    margin-left: 32rpx;
    color: #444;
    font-size: 14px;
  }
  .amount {
    font-size: 20px;
    color: #cf4444;
    &::before {
      content: '￥';
      font-size: 12px;
    }
  }
  .button-group {
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    text-align: center;
    line-height: 72rpx;
    font-size: 13px;
    color: #fff;

    .button {
      width: 240rpx;
      margin: 0 10rpx;
      border-radius: 72rpx;
    }
    .payment-button {
      background-color: #27ba9b;

      &.disabled {
        opacity: 0.6;
      }
    }
  }
}
// 底部占位空盒子
.toolbar-height {
  height: 100rpx;
}
</style>
